package school;
import java.util.HashMap;
import java.util.Map;

public class TestMain {
    public static void main(String[] args) {
        // 存储课程、教师、学生的映射
        Map<String, Course> courseMap = new HashMap<>();
        Map<String, Teacher> teacherMap = new HashMap<>();
        Map<String, Student> studentMap = new HashMap<>();

        // 创建课程
        Course course1 = new Course("C001", "Java 程序设计", "教学楼 A101", "周一 8:00-10:00", "T001");
        Course course2 = new Course("C002", "数据结构", "教学楼 B202", "周三 14:00-16:00", "T002");
        courseMap.put(course1.getCourseId(), course1);
        courseMap.put(course2.getCourseId(), course2);

        // 创建教师并关联课程
        Teacher teacher1 = new Teacher("T001", "张老师", "男", "C001");
        Teacher teacher2 = new Teacher("T002", "李老师", "女", "C002");
        teacherMap.put(teacher1.getTeacherId(), teacher1);
        teacherMap.put(teacher2.getTeacherId(), teacher2);

        // 创建学生
        Student student1 = new Student("S001", "小明", "男");
        Student student2 = new Student("S002", "小红", "女");
        studentMap.put(student1.getStudentId(), student1);
        studentMap.put(student2.getStudentId(), student2);

        // 教师开课（这里通过创建教师和课程并关联来模拟）
        System.out.println("教师开课情况：");
        System.out.println(teacher1);
        System.out.println(teacher2);

        // 学生选课
        System.out.println("\n学生选课情况：");
        student1.selectCourse("C001");
        student1.selectCourse("C002");
        student2.selectCourse("C001");
        System.out.println(student1);
        System.out.println(student2);

        // 学生退课
        System.out.println("\n学生退课情况：");
        student1.dropCourse("C002");
        System.out.println(student1);

        // 打印学生课表
        System.out.println("\n学生课表：");
        printStudentCourseSchedule(student1, courseMap, teacherMap);
        printStudentCourseSchedule(student2, courseMap, teacherMap);
    }

    // 打印学生课表方法
    public static void printStudentCourseSchedule(Student student, Map<String, Course> courseMap, Map<String, Teacher> teacherMap) {
        System.out.println("学生 " + student.getStudentName() + " 的课表：");
        for (String courseId : student.getCourseIds()) {
            Course course = courseMap.get(courseId);
            if (course != null) {
                Teacher teacher = teacherMap.get(course.getTeacherId());
                if (teacher != null) {
                    System.out.println("编号: " + course.getCourseId() + ", 课程名称: " + course.getCourseName() + ", 上课地点: " + course.getLocation() + ", 时间: " + course.getTime() + ", 授课教师: " + teacher.getTeacherName());
                }
            }
        }
        System.out.println("----------------------");
    }
}